#include <iostream>
#include <vector>
#include <sstream>

using namespace std;

struct Slot{
	Slot(bool bomb = false) : count(0), bomb(bomb) {}
	int count;
	bool bomb;
	friend ostream& operator<<(ostream& os, const Slot& s);
};

ostream& operator<<(ostream& os, const Slot& s){
	if(s.bomb)
		os << "*";
	else
		os << s.count;

	return os;
}

class Board{
	vector< vector<Slot> > items;
	int x, y;

	void boom(int bX, int bY){
		//02
		bool left = bY-1 >= 0;	//true
		bool right = bY+1 < y;	//true
		bool top = bX-1 >= 0;	//false
		bool bottom = bX+1 < x;	//true

		if(top && left)
			items[bX-1][bY-1].count++;
		if(top) //up center
			items[bX-1][bY].count++;
		if(top && right)
			items[bX-1][bY+1].count++;
		if(left) // center left
			items[bX][bY-1].count++;
		if(right) //center right
			items[bX][bY+1].count++;
		if(bottom && left)
			items[bX+1][bY-1].count++;
		if(bottom)
			items[bX+1][bY].count++;
		if(bottom && right)
			items[bX+1][bY+1].count++;

	}

	public:
	bool blank(){return (x == 0 && y == 0);}
	void fillBoard(){
		for(int d = 0; d < x; ++d){
			for(int e = 0; e < y; ++e){
				if(items[d][e].bomb){
					boom(d,e);
				}
			}
		}
		//if bomb go boom
	}
	friend istream& operator>>(istream& is, Board& b);
	friend ostream& operator<<(ostream& os, Board& b);
};

//input

istream& operator>>(istream& is, Board& b){
	is >> b.x >> b.y;
	vector<Slot> x;
	b.items.push_back(x); //new row
	for(int d = 0; d < b.x; ++d){
		for(int e = 0; e < b.y; ++e){
			char tmp;
			cin >> tmp;
			Slot x(tmp == '*');
			b.items[d].push_back(x); //new element
		}
		vector<Slot> x;
		b.items.push_back(x); //new row
	}
	return is;
}

//output

ostream& operator<<(ostream& os, Board& b){
	for(int d = 0; d < b.x; ++d){
		os << b.items[d][0];
		for(int e = 1; e < b.y; ++e){
			os << b.items[d][e];
		}
		os << endl;
	}
	return os;
}

int main(){
	ostringstream out;
	Board fBoard;
	cin >> fBoard;
	fBoard.fillBoard();
	out << "Field #1:" << endl << fBoard;
	for(int i = 2;;++i){
		Board theBoard;
		cin >> theBoard;
		if(theBoard.blank()){
			break;
		}
		theBoard.fillBoard();
		out << endl << "Field #" << i << ":" << endl;
		out << theBoard;
	}
	cout << out.str();
}
